<?php
global $_W,$_GPC;
$settings = $this->module['config'];
if(checksubmit()){
    $data['regionId'] = empty($_GPC['regionId'])?'cn-shanghai':$_GPC['regionId'];
    $data['AccessKeyID'] = $_GPC['AccessKeyID'];
    $data['AccessKeySecret'] = $_GPC['AccessKeySecret'];
    $data['accessKeyId'] = $_GPC['accessKeyId'];
    $data['accessKeySecret'] = $_GPC['accessKeySecret'];
    $data['SignName'] = $_GPC['SignName'];
    $data['TemplateCode'] = $_GPC['TemplateCode'];
    $data['nstatus'] = empty($_GPC['nstatus'])?0:$_GPC['nstatus'];
    //$data['cardprice'] = floatval($_GPC['cardprice']);
    if($_GPC['nstatus'] == 1){
        $data['nnum'] = empty($_GPC['nnum'])?1:$_GPC['nnum'];
    }else{
        $data['nnum'] = 0;
    }
    $data['lstatus'] = empty($_GPC['lstatus'])?0:$_GPC['lstatus'];
    if($_GPC['lstatus'] == 1){
        $data['lnum'] = empty($_GPC['lnum'])?1:$_GPC['lnum'];
        $data['lday'] = empty($_GPC['lday'])?30:$_GPC['lday'];
        $data['ldnum'] = empty($_GPC['ldnum'])?1:$_GPC['ldnum'];
        $data['lrole'] = $_GPC['lrole'];
    }else{
        $data['lnum'] = 0;
        $data['lday'] = 0;
        $data['ldnum'] = 0;
        $data['lrole'] = '暂无签到规则';
    }
    $data['sstatus'] = empty($_GPC['sstatus'])?0:$_GPC['sstatus'];
    if($_GPC['sstatus'] == 1){
        $data['snumber'] = empty($_GPC['snumber'])?1:$_GPC['snumber'];
        $data['snum'] = empty($_GPC['snum'])?1:$_GPC['snum'];
        $data['zsnum'] = empty($_GPC['zsnum'])?1:$_GPC['zsnum'];
    }else{
        $data['snumber'] = 0;
        $data['snum'] = 0;
        $data['zsnum'] = 0;
    }
    $data['number'] = $_GPC['number'];
    $data['pay_status'] = $_GPC['pay_status'];
    if($data['pay_status'] == 1){
        $data['mchid'] = $_GPC['mchid'];
        $data['pay_secret'] = $_GPC['pay_secret'];
        if(empty($data['mchid']) || empty($data['pay_secret'])){
            message('开启支付后，商户信息以及支付秘钥不能为空','','error');
        }
        $data['pay_set'] = 1;
    }
    $data['cardnum'] = $_GPC['cardnum'];
    $data['setheaderimg'] = $_GPC['setheaderimg'];
    $data['setuserinfo'] = $_GPC['setuserinfo'];
    $data['paylesson'] = $_GPC['paylesson'];
    $data['studylesson'] = $_GPC['studylesson'];
    $data['studylessonmax'] = $_GPC['studylessonmax'];
    $data['lookoldlesson'] = $_GPC['lookoldlesson'];
    $data['lookoldlessonmax'] = $_GPC['lookoldlessonmax'];
    $data['role'] = $_GPC['role'];
    $data['about'] = $_GPC['about'];
    $data['validtime'] = empty($_GPC['validtime'])?1440:$_GPC['validtime'];
    $data['groupnum'] = empty($_GPC['groupnum'])?3:$_GPC['groupnum'];
    $data['ip'] = $_GPC['ip'];
    //$data['h5_appid'] = $_GPC['h5_appid'];
    //$data['h5_appsecret'] = $_GPC['h5_appsecret'];
    $data['live_url'] = $_GPC['live_url'];
    $data['broad_url'] = $_GPC['broad_url'];
    $data['appname'] = $_GPC['appname'];
    $data['bucketname'] = trim($_GPC['bucketname']);
    $data['practice_status'] = $_GPC['practice_status'];

    $data['webname'] = $_GPC['webname'];
    $data['iconname'] = $_GPC['iconname'];
    $data['icontitle'] = $_GPC['icontitle'];
    $data['ntemplateid'] = $_GPC['ntemplateid'];
    $data['templateid'] = $_GPC['templateid'];
    $data['practice_remind'] = $_GPC['practice_remind'];
    $data['duanxin_status'] = $_GPC['duanxin_status'];
    $data['TemplateCode1'] = $_GPC['TemplateCode1'];
    $data['TemplateCode2'] = $_GPC['TemplateCode2'];
    $data['endpoint'] = trim($_GPC['endpoint']);
    $data['wxpaykey'] = trim($_GPC['wxpaykey']);
    $data['wxpaycert'] = trim($_GPC['wxpaycert']);
    $data['wxkey'] = $_GPC['wxkey'];
    $data['wxcert'] = $_GPC['wxcert'];
    $data['refund_status'] = $_GPC['refund_status'];

    //$data['sharetitle'] = $_GPC['sharetitle'];
    //$data['shareicon'] = $_GPC['shareicon'];
    $data['classin_status'] = $_GPC['classin_status'];
    $data['SID'] = $_GPC['SID'];
    $data['SECRET'] = $_GPC['SECRET'];
    //极光参数
    $data['jmkey'] = $_GPC['jmkey'];
    $data['jmsecret'] = $_GPC['jmsecret'];
    //极光参数
    if($data['groupnum'] > 5){
        $data['groupnum'] = 5;
    }
    if($data['groupnum'] < 3){
        $data['groupnum'] = 3;
    }

    if ($this->userid == $_W['uid']) {
        message($this->msg);
    }
    $res = $this->saveSettings($data);
    if($res){
        message('设置成功','','success');
    }else{
        message('设置失败','','error');
    }
}
include $this->template('web/settings');
?>